from sqlalchemy.orm import Session

from app.models import Message, Chat
from app.models.ai import AIAgent, AIApiKey


def getMessagesByChatId(db: Session, chat_id: int):
    """通过对话ID获取对话历史记录"""
    messages = db.query(Message).filter(Message.chat_id == chat_id).order_by(Message.id.asc()).all()
    return messages
